<script lang="ts" setup>
import IconLeft from '@/components/icons/IconLeft.vue'
import { useSlots } from 'vue'

const slots = useSlots()

const props = defineProps<{
  title?: ''
}>()
</script>

<template>
  <div class="nav-bar">
    <div class="nav-bar-placeholder"></div>
    <div class="nav-bar-main">
      <IconLeft class="nav-bar-left" />
      <h1 v-if="props.title" class="nav-bar-title">{{props.title}}</h1>
      <div v-if="slots.right" class="nav-bar-right">
        <slot name="right"></slot>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.nav-bar {
  background-color: #ffffff;
}
.nav-bar-placeholder {
  height: 88px;
}

.nav-bar-main {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 88px;
  background-color: #ffffff;

  .nav-bar-left {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    fill: #333333;
  }

  .nav-bar-title {
    margin: 0 auto;
    max-width: 60%;
    line-height: 88px;
    font-size: 32px;
    font-weight: 500;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-bar-right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
  }
}
</style>
